<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Locale"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.nithya.hms.Doctor"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hospital Management System</title>
</head>
<body>
	<%
		SimpleDateFormat format = new SimpleDateFormat("HH:mm");
		Doctor doctor = (Doctor) session.getAttribute("doctor");
		List<String> list = (List<String>)request.getAttribute("list");
	%>
	<table width="100%" border="1">
		<tr>
			<th><a href="<%=request.getContextPath()%>/secure/doctor-home.do">Today's Appointment</a></th>
			<th><a href="<%=request.getContextPath()%>/secure/doctor-schedule.do">My Schedule</a></th>
			<th><a href="<%=request.getContextPath()%>/secure/add-doctor.do">Add Doctor</a></th>
			<th><%=doctor.getFirstName()%> <%=doctor.getLastName()%></th>
			<th><a href="<%=request.getContextPath()%>/secure/logout.do">Logout</a></th>
		</tr>
		<tr>
			<td colspan="5" align="center" height="500px">
				<form action="update-schedule.do" method="post">
					<table border="1" width="600px">
						<tr>
							<th>Time / Day</th>
							<%
								Calendar c = Calendar.getInstance();
								for (int i = 1; i <= 7; i++) {
									c.set(Calendar.DAY_OF_WEEK, i);
							%>
							<td><%=c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG,
						Locale.US)%></td>
							<%
								}
							%>
						</tr>
						<%
							for (int i = 0; i < 24; i++) {
								c.set(Calendar.HOUR_OF_DAY, i);
								c.set(Calendar.MINUTE, 0);
								Date date = c.getTime();
						%>
						<tr>
							<td align="center"><%=format.format(date)%></td>
							<%
								for (int j = 1; j <= 7; j++) {
							%>
							<td align="center"><input type="checkbox" name="schedules[<%=j-1 + (i*7)%>]"
								
								<%
									String name = j + "_" + i;
									if(list.contains(name)) {
								%>
									checked="checked"
								<%		
									}
								%>
								
							
								value="<%=name%>" /></td>
							<%
								}
							%>
						</tr>
						<%
							}
						%>
						<tr>
							<td colspan="8" align="center"><input type="submit" value="Update Schedule"/> <input
								type="reset" value="Cancel"/></td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
	</table>
</body>
</html>